#!/bin/sh

. /etc/profile

LOCKDIR="/var/lock/"
LOCKFILE="${processName}"

case "$1" in
  hibernate|suspend)
  	PID=`ps aux | grep ${processName} | grep -v grep | awk '{print $1}'`
    if [ -n "${PID+x}" ];then
      progress "Shutting down ${processName} for suspending..."
      mkdir -p "$LOCKDIR"
      touch "$LOCKDIR/$LOCKFILE"
      kill $PID
    fi
    ;;

  thaw|resume)
    if [ -f "$LOCKDIR/$LOCKFILE" ];then
      progress "Restarting ${processName} for wake-up ..."
      ${processName}.service
      rm -rf "$LOCKDIR/$LOCKFILE"
    fi
    ;;

  *) exit $NA
    ;;
esac
